<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.Calendar"%>
<%@ page import="hmg.vo.BoardVO"%>
<%@ page import="java.util.List"%>
<%-- 
    JSP Name : jspName.jsp
    Description : 설명을 기술합니다.
    author Kim hyung soo
    since 2012. 10. 5.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 10. 5.     Kim hyung soo     최초 생성
--%>
<%
    Integer year = (Integer) request.getAttribute("Year");
    Integer month = (Integer) request.getAttribute("Month");
    Integer startDay = (Integer) request.getAttribute("StartDay");
    Integer lastDate = (Integer) request.getAttribute("LastDate");
    List<BoardVO> monthlyNewsList = (List<BoardVO>) request.getAttribute("MonthlyNewsList");

    int currYear = Calendar.getInstance().get(Calendar.YEAR);           //현재년
    int currMonth = Calendar.getInstance().get(Calendar.MONTH) + 1;     //현재월
    int currDate = Calendar.getInstance().get(Calendar.DATE);           //현재일
%>
<script type="text/javascript" src="/hmg/js/web/kor/com/googleAnalytics.js"></script>
            <div class="photo_mask"></div>
            <div class="photo_layPop">
                <p class="btnClose"><a href="#"><img src="/hmg/images/web/kor/mgr/gallery_Slide_Close.png" alt="닫기"/></a></p>
                <div id="schedule_wrapper">
                    <div class="schedule_scroll">
                        <div class="schedule_scrollContainer">
                            <div class="schduleList line6">
                                <div class="titleWrap">
                                    <p class="title"><img src="/hmg/images/web/kor/gbc/schedule/schedule_title.gif" alt="닫기"/></p>
                                    <div class="monthSelect">
                                        <ul>
                                            <li><a href="#" onclick="javascript:fn_move_scheduleTable(<%= year %>, <%= month - 1 %>);"><img src="/hmg/images/web/kor/gbc/schedule/btn_prev.gif" alt="이전달"/></a></li>
                                            <li class="month"> <%= year %> <img src="/hmg/images/web/kor/gbc/schedule/text_year.gif" alt="년" class="pr10"/> <%= month %> <img src="/hmg/images/web/kor/gbc/schedule/text_month.gif" alt="월"/></li>
                                            <li><a href="#" onclick="javascript:fn_move_scheduleTable(<%= year %>, <%= month + 1 %>);"><img src="/hmg/images/web/kor/gbc/schedule/btn_next.gif" alt="다음달"/></a></li>
                                        </ul>
                                    </div>
                                </div>

                                <div class="scheduleTable">
                                    <table summary="그룹방송  On-Air 편성표 목록">
                                        <caption>그룹방송  On-Air 편성표</caption>
                                        <colgroup>
                                            <col width="90px"/>
                                            <col width="89px"/>
                                            <col width="90px"/>
                                            <col width="89px"/>
                                            <col width="90px"/>
                                            <col width="91px"/>
                                            <col width="91px"/>
                                        </colgroup>
                                        <thead>
                                            <tr>
                                                <th scope="col"><img src="/hmg/images/web/kor/gbc/schedule/text_sun.gif" alt="Sunday" /></th>
                                                <th scope="col"><img src="/hmg/images/web/kor/gbc/schedule/text_mon.gif" alt="Monday" /></th>
                                                <th scope="col"><img src="/hmg/images/web/kor/gbc/schedule/text_tues.gif" alt="Tuesday" /></th>
                                                <th scope="col"><img src="/hmg/images/web/kor/gbc/schedule/text_wed.gif" alt="Wednesday" /></th>
                                                <th scope="col"><img src="/hmg/images/web/kor/gbc/schedule/text_thur.gif" alt="Thursday" /></th>
                                                <th scope="col"><img src="/hmg/images/web/kor/gbc/schedule/text_fri.gif" alt="Friday" /></th>
                                                <th scope="col"><img src="/hmg/images/web/kor/gbc/schedule/text_sat.gif" alt="Saturday" /></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
<%  for (int idx = 1; idx < startDay; idx++) { %>
                                                <td class="bg">
                                                    <div class="schedule_Daylist_wrap">
                                                        &nbsp;
                                                    </div>
                                                </td>
<%
    }

    int listIdx = 0;
    for (int idx = 0; idx < lastDate; idx++) {
        String tdClassName = "";
        String aClassName = "";
        String liClassName = "";

        if (currYear == year && currMonth == month && idx + 1 == currDate)
            tdClassName = "blue";
        else if ((startDay + idx - 1) % 7 == 0)
            tdClassName = "red";

        for (int jdx = 0; monthlyNewsList != null && jdx < monthlyNewsList.size(); jdx++) {
            BoardVO monthlyNews = monthlyNewsList.get(jdx);

            if (idx + 1 == Integer.parseInt(monthlyNews.getEffectDate().substring(8, 10)))
                aClassName = "on";
        }

        if (idx != 0 && (startDay + idx - 1) % 7 == 0) {
            out.println("                                            </tr>");
            out.println("                                            <tr>");
        }
%>   
                                                <td class="<%= tdClassName %> bg">
                                                    <div class="schedule_Daylist_wrap">
                                                        <a href="#" class="<%= aClassName %>"><%= idx + 1 %></a>
                                                    </div>
<%      if (monthlyNewsList != null && monthlyNewsList.size() > listIdx && idx + 1 == Integer.parseInt(monthlyNewsList.get(listIdx).getEffectDate().substring(8, 10))) { %>
                                                    <!--daylist-->
                                                    
<%          if (idx < 15) { %>
                                                    <div class="schedule_Daylist">
                                                        <div class="schedule_Daylist_scroll">
<%          
            }
            else {
%>
                                                    <div class="schedule_Daylist02">
                                                        <div class="schedule_Daylist02_scroll">
<%          } %>
                                                            <div class="scroll-pane" >
                                                                <ul>
<%
            liClassName = "first";
            while (listIdx < monthlyNewsList.size() && idx + 1 == Integer.parseInt(monthlyNewsList.get(listIdx).getEffectDate().substring(8, 10))) {            
                BoardVO monthlyNews = monthlyNewsList.get(listIdx);

                if (idx + 1 == Integer.parseInt(monthlyNews.getEffectDate().substring(8, 10))) {
                    String title = monthlyNews.getTitle();
                    
                    if (monthlyNews.getSubtitle() != null && monthlyNews.getSubtitle().length() > 0)
                        title = monthlyNews.getSubtitle() + " - " + title;
%>
                                                                    <li class="<%= liClassName %>">
                                                                        <a href="./GroupBroadcastView.do?listID=<%= monthlyNews.getListID() %>&listType=0&page=1"><div style="width:360px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;"><span class="f_bold"> <%= monthlyNews.getListName() %></span> <%= title %></div></a>
                                                                    </li>
<%
                }

                liClassName = "";
                listIdx++;
            }
%>
                                                                </ul>
                                                                <p class="close_btn"><a href="#"><img src="/hmg/images/web/kor/gbc/schedule/close_btn.gif" alt="닫기"/></a></p>
                                                            </div>
                                                        </div>
<%          if (idx < 15) { %>
                                                        <div class="schedule_Daylist_bottom">&nbsp;</div>
<%
            }
            else {
%>
                                                        <div class="schedule_Daylist_bottom02">&nbsp;</div>
<%          } %>
                                                    </div>
                                                    <!--//daylist-->
<%      } %>
                                                </td>
<%
    }

    if ((startDay + lastDate) % 7 != 6) {
        for (int idx = 0; (idx + startDay + lastDate - 1) % 7 != 0; idx++) {
%>
                                                <td>
                                                    <div class="schedule_Daylist_wrap">
                                                        &nbsp;
                                                    </div>
                                                </td>
<%
        }

    }
%>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
<script type="text/javascript">
fe_layPop2();
</script>